#!/bin/sh
if [ "$0" == "./$(basename $0)" ]
then
    echo please exec shell for "/tools/monitor/probe/daemon.sh"
    exit 1
fi
daemon=`ps -ef|grep -v grep|grep -w -c "/tools/monitor/probe/daemon.sh"`
if [ "$daemon" -gt 2 ];then
    exit 1
fi
while True
ulimit -c unlimited
do
P=`ps -ef|grep -Ev "daemon.sh|grep"|grep -w -c main.py`
if [ "$P" -eq 0 ]
    then
        date=`date`
        echo "$date" >> /var/log/monitor_probe.log
        cd /tools/monitor/probe/ && python main.py
        sleep 2
fi
done
